package com.example.crm.servlet;

import com.example.crm.pojo.Customer;
import com.example.crm.service.ICustomerService;
import com.example.crm.service.impl.CustomerServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/customer/list")
public class CustomerListServlet extends HttpServlet
{
    ICustomerService customerService = new CustomerServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 1. 获取参数

        // 2. 调用service
        List<Customer> list = customerService.findAll();
        req.setAttribute("list",list);

        // 3. 请求转发
        req.getRequestDispatcher("/WEB-INF/jsp/customer/list.jsp").forward(req,resp);

    }
}
